//
//  BaseTableViewController.swift
//  SinaWeibo
//
//  Created by 李旭阳 on 15/11/9.
//  Copyright © 2015年 apple. All rights reserved.
//

import UIKit

class BaseTableViewController: UITableViewController,VisitorLoginViewDelegate {
    //添加用户登录标记
    var userLogin = UserAccountViewModel().userLogin
    var visitorLoginView: VisitorLoginView?
    
    override func loadView(){
        userLogin ? super.loadView() : loadVisitorView()
    }
    
    private func loadVisitorView(){
        visitorLoginView = VisitorLoginView()
        
        //设置代理
        visitorLoginView?.visitorDelegate = self
        
        view = visitorLoginView
        
        navigationItem.leftBarButtonItem = UIBarButtonItem(title: "登陆", style: .Plain, target: self, action: "visitorWillLogin")
        navigationItem.rightBarButtonItem = UIBarButtonItem(title: "注册", style: .Plain, target: self, action: "visitorWillRegister")
    }
    
    func visitorWillLogin() {
        print("come in")
        let oauth = OAuthViewController()
        let nav = UINavigationController(rootViewController: oauth)
        //model 出 登陆页面控制器
        presentViewController(nav, animated: true, completion: nil)
    }
    func visitorWillRegister() {
        print("come on")
    }
    

}
